package com.example.socialwebserver.controller;

import com.example.socialwebserver.pojo.ExpectLoveDAO;
import com.example.socialwebserver.pojo.ServerResult;
import com.example.socialwebserver.service.ExpectLoveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class ExpectLoveController {
    @Autowired
    ExpectLoveService expectLoveService;

    @RequestMapping("expectLove/SelectById")
    public ServerResult SelectById(Integer id){
        ExpectLoveDAO expectLoveDAO = expectLoveService.SelectById(id);
        return expectLoveDAO == null?new ServerResult(-1,"失败",null):
                new ServerResult(0,"成功",expectLoveDAO);
    }
    @RequestMapping("expectLove/InsertExFrDAO")
    public ServerResult InsertExFrDAO(ExpectLoveDAO expectLoveDAO){
        boolean b = expectLoveService.InsertExLoDAO(expectLoveDAO);
        return b == true?new ServerResult(0,"添加成功",b): new ServerResult(0,"添加失败",b);
    }
    @RequestMapping("expectLove/DeleteById")
    public ServerResult DeleteById(Integer id){
        boolean b = expectLoveService.DeleteById(id);
        return b == true?new ServerResult(0,"添加成功",b): new ServerResult(0,"添加失败",b);
    }
    @RequestMapping("expectLove/UpdateById")
    public ServerResult UpdateById(ExpectLoveDAO expectLoveDAO) {
        boolean b = expectLoveService.UpdateById(expectLoveDAO);
        return b == true?new ServerResult(0,"修改成功",b): new ServerResult(0,"修改失败",b);
    }

}
